package pl.edu.agh.abd.hsm;

import java.io.IOException;
import org.codehaus.jackson.map.ObjectMapper;
import org.restlet.resource.ClientResource;
import org.restlet.resource.ResourceException;

public class SimpleClient {
	public static void main(String[] args) throws InterruptedException {
		// Create the client resource  
		if(args.length > 0){
			for(String arg : args){
				ClientResource resource = new ClientResource("http://localhost:8182/estimator/" + arg);  
				
				try {
					ObjectMapper mapper = new ObjectMapper();
					EstimatorResponse es = mapper.readValue(resource.get(String.class), EstimatorResponse.class);
					System.out.println("Resource: " + es.getResourceName());
					System.out.println("Latency:  " + es.getLatencyTime() + "ms");
					System.out.println("Transfer: " + es.getTransferTime() + "ms");
				} catch (ResourceException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		

	}
}
